jsx3.Class.defineClass(
        "tibco.admin.monitormanage.uicomponents.table.nodes.Nodes", //the full name of the class to create
        jsx3.gui.Block, //  extends
        null, // implements
        function (plugin) {
        	plugin.wsEndpointURL = tibco.admin.monitormanage.framework.mainPage.MainPage.wsEndpointURL;
        	plugin.nodesTableCacheId = "SPM_NODES_TABLE_CACHE";
        	plugin.nodesHierarchicalTableCacheId = "SPM_NODES_HIERARCHICAL_TABLE_CACHE";
        	plugin.nodesFlatTableCacheId = "SPM_NODES_FLAT_TABLE_CACHE";
        	plugin.dashboardScreenId = "tibco.admin.monitormanage.uicomponents.page.dashboard.Dashboard.dashboardScreen";
        	plugin.prototype.showAllMetrics = false;
        	plugin.prototype.isHierarchical = false;
        	plugin.prototype.renderModelHierarchical = true;
        	plugin.prototype.nodesFlatTableCacheInitialized = false;
        	plugin.prototype.cacheIdForNodes;
        	plugin.prototype.cacheSubjectForNodes;
        	plugin.prototype.listenForEnvironment;
        	plugin.prototype.screenId;
			plugin.prototype.nameSuffix = "";
        	plugin.prototype.allowAllEnvironments;
        	plugin.prototype.selectedNodeIds;
        	
        	plugin.prototype.machineId;
        	plugin.prototype.toggledRowIds;
        	plugin.prototype.columnDisplayHandled;
        	
        	plugin.columnsToExclude = ["numContainersCol","uptimeCol","cpuTimeCol"];
        
            plugin.prototype.init = function() {
                this.jsxsuper();
            }
            
            plugin.prototype.getNamespace = function() {
				return "tibco.admin";
			}

        	plugin.showNodeDetail = function(nodeIdVal) {
        		var paramArray = { nodeId:nodeIdVal };
        		tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.nodeScreenId, paramArray); 
        	}
			
			plugin.showMachineDetail = function(machineIdVal) {
        		var paramArray = { machineId:machineIdVal };
        		tibco.admin.monitormanage.general.NavigationHandler.publishMainPageNavigationMessage(tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.machineScreenId, paramArray); 
        	}
        	
        	plugin.prototype.rowToggled = function(recordId) {
        		if(this.isHierarchical)
        		{
	        		if(this.toggledRowIds.contains(recordId))
	        		{ this.toggledRowIds.remove(recordId); }
	        		else
	        		{ this.toggledRowIds.add(recordId); }
        		}
        	}
			
			plugin.prototype.setUpComponent = function(nameSuffix, showAllMetrics, isHierarchical, cacheIdForNodes, cacheSubjectForNodes, listenForEnvironment, allowAllEnvironments, screenId, loadDataImmediately, showStartStopButtons) {
				if(isHierarchical)
				{ 
					tibco.admin.Main.getServer().Cache.clearById(plugin.nodesHierarchicalTableCacheId);
					tibco.admin.Main.getServer().Cache.clearById(plugin.nodesFlatTableCacheId); 
				}
				else
				{ tibco.admin.Main.getServer().Cache.clearById(plugin.nodesTableCacheId); }
				
				this.showAllMetrics = showAllMetrics;
				this.isHierarchical = isHierarchical;
				this.renderModelHierarchical = true;
				this.nodesFlatTableCacheInitialized = false;
				this.cacheIdForNodes = cacheIdForNodes;
				this.cacheSubjectForNodes = cacheSubjectForNodes;
				this.screenId = screenId;
				this.nameSuffix = nameSuffix;
				this.listenForEnvironment = listenForEnvironment;
				this.allowAllEnvironments = allowAllEnvironments;
				this.columnDisplayHandled = false;
				if(isHierarchical)
				{ this.toggledRowIds = new jsx3.util.List(); }
				this.selectedNodeIds = new jsx3.util.List();
				var tableLabel = this.getDescendantOfName("nodesTableLabel");
				tableLabel.setName(tableLabel.getName() + nameSuffix);
				var nodesHelpButton = this.getDescendantOfName("nodesHelpButton");
				nodesHelpButton.setName(nodesHelpButton.getName() + nameSuffix);
				var startButton = this.getDescendantOfName("startButton");
				startButton.setName(startButton.getName() + nameSuffix);
				var stopButton = this.getDescendantOfName("stopButton");
				stopButton.setName(stopButton.getName() + nameSuffix);
				var tableModeToggleImg = this.getDescendantOfName("tableModeToggleImg");
				tableModeToggleImg.setName(tableModeToggleImg.getName() + nameSuffix);
				var nodesTable = this.getDescendantOfName("nodesTable");
				nodesTable.setName(nodesTable.getName() + nameSuffix);
				
				var server = tibco.admin.Main.getServer();
				var graphCol = nodesTable.getDescendantOfName("memoryCol");
				var backgroundImg = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarBkgrdTile.jpg');
				var redFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarRedFill.jpg');
				var greenFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarGreenFill.jpg');
				var yellowFill = server.resolveURI('jsxaddin://user!MatrixAdmin/images/matrix/progressBarYellowFill.jpg');
				var valueTemplate = graphCol.getValueTemplate();
				valueTemplate = valueTemplate.replace("___BACKGROUND___", backgroundImg);
				valueTemplate = valueTemplate.replace("___REDFILL___", redFill);
				valueTemplate = valueTemplate.replace("___GREENFILL___", greenFill);
				valueTemplate = valueTemplate.replace("___YELLOWFILL___", yellowFill);
				graphCol.setValueTemplate(valueTemplate);
				
	            tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.selectedTimeframeSubject, this.timeframeSelected, this);
	            if(listenForEnvironment)
	            { tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.environmentChangeSubject, this.environmentSelected, this); }	            
				
				if(cacheIdForNodes && cacheSubjectForNodes)
				{
					// Node keys are going to be used to populate the data
            		tibco.admin.monitormanage.general.PageBusUtils.subscribe(cacheSubjectForNodes, this.loadContent, this);
				}
				else if(loadDataImmediately)
				{ 
					tibco.admin.monitormanage.general.PageBusUtils.subscribe(tibco.admin.monitormanage.general.NavigationHandler.mainPageDisplayTopic, this.handleDisplayScreen, this);
					this.callGetNodes(this);
				}
				
				if(showStartStopButtons)
				{
					this.getDescendantOfName("startStopButtonsBlock").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
					this.getDescendantOfName("nodesLayoutHorizontal").setRows("33,*", true);
				}else{
					this.getDescendantOfName("nodesLayoutHorizontal").setRows("28,*", true);
				}

                var nodesHelpObj=this.getDescendantOfName("nodesHelpButton" + this.nameSuffix);
                nodesHelpObj.setEvent("this.getAncestorOfName('nodesBlock').nodesHelpImgClicked(objEVENT)", "jsxexecute");

                if(this.screenId==plugin.dashboardScreenId)
                	nodesHelpObj.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
            }

            plugin.prototype.nodesHelpImgClicked=function(objEVENT){
                var nodesHelpObj=this.getDescendantOfName("nodesHelpButton" + this.nameSuffix);
                if(this.screenId==tibco.admin.monitormanage.uicomponents.page.deployment.Deployment.serviceUnitScreenId)
                    nodesHelpObj.openHelp("MonitorManage.Deployment.Nodes", "tibco.admin", objEVENT);
                if(this.screenId==tibco.admin.monitormanage.uicomponents.page.gridInfrastructure.GridInfrastructure.environmentScreenId)
                    nodesHelpObj.openHelp("MonitorManage.Infrastructure.Nodes ", "tibco.admin", objEVENT);

            }
			
            plugin.prototype.timeframeSelected = function(subject, message, tableObj) {
            	var timeframeId = message.selectedTimeframe;
            	tableObj.callGetNodes(tableObj, null, timeframeId, tableObj.listenForEnvironment);
            }
            
            plugin.prototype.environmentSelected = function(subject, message, tableObj) {
            	var envId = message.environmentId;
            	tableObj.callGetNodes(tableObj, null, null, tableObj.listenForEnvironment, envId);
            }
            
            plugin.prototype.updateComponent = function() {
            	var makeWSCall = false;
            	if(!this.listenForEnvironment)
            	{ makeWSCall = true; }
            	else
            	{
            	 	if(this.allowAllEnvironments)
            	 	{ makeWSCall = true; }
            	 	else
            	 	{
            	 		var environmentId = tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.getCurrentEnvironmentId();
            	 		if(environmentId && environmentId != "" && environmentId != tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.allEnvironmentsId)
            	 		{ makeWSCall = true; }
            	 	}
            	}
            	if(makeWSCall)
				{ this.callGetNodes(this, null, null, this.listenForEnvironment, null); }
			}
			
			plugin.prototype.handleDisplayScreen = function(subject, message, tableObj) {
            	if(message.screenId == tableObj.screenId)
            	{ 
            		if(message.machineId)
            		{ tableObj.machineId = message.machineId; }
            		
            		var environmentId = null; 
            		var makeWSCall = false;
            		if(!tableObj.listenForEnvironment)
            		{ makeWSCall = true; }
            		else
            		{
            	 		if(tableObj.allowAllEnvironments)
            	 		{ makeWSCall = true; }
            	 		else
            	 		{
            	 			environmentId = message.environmentId;
            	 			if(!environmentId)
            	 			{ environmentId = tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.getCurrentEnvironmentId(); }
            	 			if(environmentId && environmentId != "" && environmentId != tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.allEnvironmentsId)
            	 			{ makeWSCall = true; }
            	 		}
            		}	
            		if(makeWSCall)
					{ tableObj.callGetNodes(tableObj, null, null, tableObj.listenForEnvironment, environmentId); }
            	}
            }
			
			plugin.prototype.toggleRenderingModel = function() {
				var tableCacheId;
				if(this.renderModelHierarchical)
				{
					// render mode has been switched to flat mode
					this.renderModelHierarchical = false;
					tableCacheId = plugin.nodesFlatTableCacheId;
				
					if(!this.nodesFlatTableCacheInitialized)
					{
						// initialize the cache for the flat table
						var flatCacheDoc = jsx3.xml.CDF.Document.newDocument();
						var server = tibco.admin.Main.getServer();
						var hierarchicalCacheDoc = server.Cache.getDocument(plugin.nodesHierarchicalTableCacheId);
						var envRecords = hierarchicalCacheDoc.getChildNodes();
						for(i = 0; i < envRecords.size(); i++)
						{
							var envRecord = envRecords.get(i);
							var nodeRecords = envRecord.getChildNodes();
							for(j = 0; j < nodeRecords.size(); j++)
							{
								var nodeRecord = nodeRecords.get(j);
								var clonedNodeRecord = nodeRecord.cloneNode();
								flatCacheDoc.appendChild(clonedNodeRecord);
							}
						}
						server.Cache.setDocument(plugin.nodesFlatTableCacheId, flatCacheDoc);
						
						this.nodesFlatTableCacheInitialized = true;
					}
				}
				else
				{
					// render mode has been switched to hierarchical mode
					this.renderModelHierarchical = true;
					tableCacheId = plugin.nodesHierarchicalTableCacheId;
				}
				plugin.setRenderModelToggleImage(this);
				
				var nodesTable = this.getDescendantOfName("nodesTable" + this.nameSuffix);
				nodesTable.setXMLId(tableCacheId);
				nodesTable.repaint();
			}
			
			/**
			*  This is only invoked when the node keys are going to be specified in the getNodes call
			*/
			plugin.prototype.loadContent = function(subject, message, nodesObj) {
            	var nodesDoc = tibco.admin.Main.getServer().Cache.getDocument(nodesObj.cacheIdForNodes);
           		if(nodesDoc)
           		{
            		nodesObj.contentLoaded = true;
            			
            		// initialize the node key list from the cache
            		var nodeKeyList = new jsx3.util.List();
            		var records = nodesDoc.getChildNodes();
            		for(i = 0; i < records.size(); i++)
            		{
            			var nodeRecord = records.get(i);
            			var nodeKey = nodeRecord.getAttribute("nodeKey");
            			nodeKeyList.add(nodeKey);
            		}
            			
           			nodesObj.callGetNodes(nodesObj, nodeKeyList);
           		}
			}
			
			plugin.prototype.tableSelectionsChanged = function() {
				this.selectedNodeIds.clear();
				var enableStart = false;
				var enableStop = false;
				var startButtonState = jsx3.gui.Form.STATEDISABLED;
				var stopButtonState = jsx3.gui.Form.STATEDISABLED;
				var recordIter = this.getDescendantOfName("nodesTable" + this.nameSuffix).getSelectedNodes().iterator();
                while(recordIter.hasNext()) {
	            	var record = recordIter.next();
                    var status = record.getAttribute("status");
                    if(status == "Stopped" || status == "Installed/Stopped")
                    { 
                    	startButtonState = jsx3.gui.Form.STATEENABLED; 
                    	enableStart = true;
                    }
                    else if(status == "Running")
                    { 
                    	stopButtonState = jsx3.gui.Form.STATEENABLED; 
                    	enableStop = true;
                    }
                    var recordId = record.getAttribute("jsxid");
                    this.selectedNodeIds.add(recordId);
                }
                this.getDescendantOfName("startButton" + this.nameSuffix).setEnabled(startButtonState, true);
                this.getDescendantOfName("stopButton" + this.nameSuffix).setEnabled(stopButtonState, true);
			}
			
			plugin.prototype.startStopNodes = function(isStart) {
				try {
					var objService;
					var rulesPath = "tibco/admin/monitormanage/uicomponents/table/nodes/rules/startNodesRules.xml";
					var dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/startNodesData.xml";
					var operation = "startNodes";
					if(isStart)
					{
						rulesPath = "tibco/admin/monitormanage/uicomponents/table/nodes/rules/startNodesRules.xml";
						dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/startNodesData.xml";
						operation = "startNodes";
					}
					else
					{
						rulesPath = "tibco/admin/monitormanage/uicomponents/table/nodes/rules/stopNodesRules.xml";
						dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/stopNodesData.xml";
						operation = "stopNodes";
					}
					if (tibco.admin.Main.getServer().getEnv("MODE")) {
	                    // mode is live
	                    objService = tibco.admin.Main.loadService(this.getNamespace(), rulesPath, operation);
	                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getNodeEndpointURL());
	                    // this setInboundURL should not be required...only here because of a current AMX framework bug
			    		objService.setInboundURL(dataPath);
	                }
	                else {
	                    objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(this.getNamespace(), rulesPath), operation, null, null);
	                    objService.setInboundURL(tibco.admin.Main.resolveURI(this.getNamespace(), dataPath));
	                }
                
                    var nodeList = new jsx3.util.List(0);
                    var recordIter = this.getDescendantOfName("nodesTable" + this.nameSuffix).getSelectedNodes().iterator();
                    while(recordIter.hasNext()) {
	                    var record = recordIter.next();
                        var obj = new Object();
                        obj.nodeId = record.getAttribute("key");
                        obj.nodeName = record.getAttribute("name");
                        jsx3.log("node key = " + obj.nodeId);
                        jsx3.log("node name = " + obj.nodeName);
                        nodeList.add(obj, nodeList.size());
                    }
                    objService.nodesIter = nodeList.iterator();
                    
                    objService.nodesObj = this;

                    //subscribe and call
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this.onstartStopNodesSuccess);
                    objService.subscribe(jsx3.net.Service.ON_ERROR, this.onstartStopNodesError);
                    objService.subscribe(jsx3.net.Service.ON_INVALID, this.onstartStopNodesInvalid);
                    objService.doCall();
                }
                catch(ex) {
                	tibco.admin.Main.logException(ex, "Error in tibco.admin.monitormanage.uicomponents.table.nodes.Nodes.startStopNodes");
                }
			}
			
			plugin.prototype.onstartStopNodesSuccess = function(objEvent) {
	      		//var responseXML = objEvent.target.getInboundDocument();
	      		//jsx3.log("Success","The service call was successful.");
	      		var nodesObj = objEvent.target.nodesObj;
	      		nodesObj.callGetNodes(nodesObj);
	    	};
	
	    	plugin.prototype.onstartStopNodesError = function(objEvent) {
	      		var myStatus = objEvent.target.getRequest().getStatus();
	      		jsx3.log("Error","The service call failed. The HTTP Status code is: " + myStatus);
	    	};
	
	    	plugin.prototype.onstartStopNodesInvalid = function(objEvent) {
	      		jsx3.log("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
	    	};
			
			//call this method to begin the service call (eg.service.callgetNodes();)
    		plugin.prototype.callGetNodes = function(nodesObj, nodeKeyList, timeframeId, listenForEnvironment, environmentId) {
    			var rulesPath = "tibco/admin/monitormanage/uicomponents/table/nodes/rules/nodesTableRules.xml";
    			var dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/nodesTableData.xml";
    			if(nodeKeyList)
    			{ dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/nodesTableDataForKeysInput.xml"; }
    			var operation = "getNodes";
    			if(nodesObj.isHierarchical)
    			{ 
    				rulesPath = "tibco/admin/monitormanage/uicomponents/table/nodes/rules/nodesHierarchicalTableRules.xml"; 
    				dataPath = "tibco/admin/monitormanage/uicomponents/table/nodes/data/nodesHierarchicalTableData.xml";
    				operation = "getNodesByEnvironments";
					nodesObj.machineId = this.machineId;
    			}
    		
      			if(tibco.admin.Main.getServer().getEnv("MODE")) 
    			{
					// mode is live
					var objService = tibco.admin.Main.loadService(nodesObj.getNamespace(), rulesPath, operation);
					objService.setEndpointURL(plugin.wsEndpointURL);
					// this setInboundURL should not be required...only here because of a current AMX framework bug
					objService.setInboundURL(dataPath);
				}
				else 
				{
					var objService = new jsx3.net.Service(tibco.admin.Main.resolveURI(nodesObj.getNamespace(), rulesPath), operation, null, null);
					// mode is static
					objService.setInboundURL(tibco.admin.Main.resolveURI(nodesObj.getNamespace(), dataPath));
				}
				
				objService.nodeObj = nodesObj;
				
				if(!timeframeId)
				{ timeframeId = tibco.admin.monitormanage.uicomponents.dropdown.timeframe.Timeframe.getCurrentTimeframeId(); }
				objService.timeframeId = timeframeId;
				if(listenForEnvironment)
				{
					if(!environmentId)
					{ environmentId = tibco.admin.monitormanage.uicomponents.dropdown.environment.Environment.getCurrentEnvironmentId(); }
					objService.environmentId = environmentId;
				}
				if(nodesObj.machineId)
				{ objService.machineId = nodesObj.machineId; }
				
				// initialize the list of metrics we wish to retrieve data for
				var metricsList = new jsx3.util.List();
				metricsList.add("status");
				metricsList.add("numServices");
				metricsList.add("faults");
				metricsList.add("successes");
				metricsList.add("machine");
				metricsList.add("machineKey");
				metricsList.add("memoryInUse");
				metricsList.add("totalMemory");
				if(nodesObj.showAllMetrics)
				{
					metricsList.add("numContainers");
					metricsList.add("upTime");
					metricsList.add("cpuTime");
				}
				objService.metricsList = metricsList;
				
				if(!nodeKeyList)
				{ nodeKeyList = new jsx3.util.List(); }
				objService.nodeKeyList = nodeKeyList; 

      			//subscribe and call
      			objService.subscribe(jsx3.net.Service.ON_SUCCESS, nodesObj.ongetNodesSuccess);
      			objService.subscribe(jsx3.net.Service.ON_ERROR, nodesObj.ongetNodesError);
      			objService.subscribe(jsx3.net.Service.ON_INVALID, nodesObj.ongetNodesInvalid);
      			objService.doCall();
    		}

    		plugin.prototype.ongetNodesSuccess = function(objEvent) {
      			//var responseXML = objEvent.target.getInboundDocument();
      			//jsx3.log("Success","The service call was successful.");
      			var nodeObj = objEvent.target.nodeObj;
      			var nodeTable = nodeObj.getDescendantOfName("nodesTable" + nodeObj.nameSuffix);
      			
      			var cacheId = plugin.nodesTableCacheId;
      			var renderingModel = "shallow";
      			if(nodeObj.isHierarchical)
      			{ 
      				cacheId = plugin.nodesHierarchicalTableCacheId; 
      				renderingModel = "hierarchical";
      			}
      			
      			if(nodeTable.getXMLId != cacheId)
      			{ nodeTable.setXMLId(cacheId); }
				if(nodeTable.getRenderingModel() != renderingModel)
      			{ nodeTable.setRenderingModel(renderingModel); }
      			
      			// update the cache to correctly populate the attribute data
      			var nodesTableDoc = tibco.admin.Main.getServer().Cache.getDocument(cacheId);
      			if(nodeObj.isHierarchical)
      			{
      				var envRecords = nodesTableDoc.getChildNodes();
      				for(i = 0; i < envRecords.size(); i++)
      				{
      					var envRecord = envRecords.get(i);
      					envRecord.setAttribute("hideLink", "true");
      					var nodeRecords = envRecord.getChildNodes();
      					plugin.handleNodesCacheAttributes(nodeRecords);
      				}
      				
      				// now make sure we persist the toggled rows
      				for(j = 0; j < nodeObj.toggledRowIds.size(); j++)
      				{
      					var rowId = nodeObj.toggledRowIds.get(j);
      					nodeTable.toggleItem(rowId, true);
      				}
      			}
      			else
      			{ 
      				var records = nodesTableDoc.getChildNodes(); 
      				plugin.handleNodesCacheAttributes(records);
      			}
      			tibco.admin.Main.getServer().Cache.setDocument(cacheId, nodesTableDoc);
      			
      			// handle the hierarchical display toggle if necessary
      			if(nodeObj.isHierarchical)
      			{ plugin.setRenderModelToggleImage(nodeObj); }

				var repaintTable = false;      			
      			if(!nodeObj.columnDisplayHandled)
      			{
      				nodeObj.columnDisplayHandled = true;
      				
      				// now appropriately hide or show the columns
      				var colDisplayStyle = jsx3.gui.Block.DISPLAYNONE;
      				if(nodeObj.showAllMetrics)
      				{ colDisplayStyle = jsx3.gui.Block.DISPLAYBLOCK; }
      				for(i = 0; i < plugin.columnsToExclude.length; i++)
      				{
      					var col = nodeTable.getDescendantOfName(plugin.columnsToExclude[i]);      				
      					col.setDisplay(colDisplayStyle);
      				}
      				repaintTable = true;
      			}
      			
      			// reselect the selected rows
      			var selectedIdsIter = nodeObj.selectedNodeIds.iterator();
      			while(selectedIdsIter.hasNext())
      			{
      				var selectedId = selectedIdsIter.next();
      				nodeTable.selectRecord(selectedId);
      			}
				nodeObj.tableSelectionsChanged();
      			
      			if(repaintTable)
      			{ nodeTable.repaint(); }
      			else
      			{ nodeTable.repaintData(); }
    		}
    		
    		plugin.setRenderModelToggleImage = function(nodeObj) {
    			var toggleImgSrc;

  				var toggleImg = nodeObj.getDescendantOfName("tableModeToggleImg" + nodeObj.nameSuffix);

  				if(!nodeObj.renderModelHierarchical)
      			{ toggleImgSrc = "jsxaddin://user!MatrixAdmin/images/matrix/hierarchical.gif"; }
      	  else
      			{ toggleImgSrc = "jsxaddin://user!MatrixAdmin/images/matrix/nonhierarchical.gif"; }
      			
      			toggleImg.setSrc(toggleImgSrc);
      			toggleImg.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
      			toggleImg.repaint();
    		}
    		
    		plugin.handleNodesCacheAttributes = function(records) {
    			for(k = 0; k < records.size(); k++)
      			{
      				var record = records.get(k);
      				
      				// create the faults/successes attribute
      				var faultsSuccesses = record.getAttribute("faults") + "/" + record.getAttribute("successes");
                    var faultsSuccessesValue = record.getAttribute("faults")/record.getAttribute("successes");
                    record.setAttribute("faultsSuccessesValue", faultsSuccessesValue);
                    record.setAttribute("faultsSuccesses", faultsSuccesses);

      				var memoryInUse = record.getAttribute("memoryInUse");
      				var totalMemory = record.getAttribute("totalMemory");
      				memoryInUse = plugin.formatToMB(memoryInUse);
      				totalMemory = plugin.formatToMB(totalMemory);
      				var memoryRatio = memoryInUse + "/" + totalMemory;
      				record.setAttribute("memoryRatio", memoryRatio);
      				var memoryPercent = ((memoryInUse-0) / (totalMemory-0)) * 100;
      				record.setAttribute("memoryPercent", memoryPercent);
      			}
    		}
    		
    		plugin.formatToMB = function(num) {
    			num = (num-0)/1000000;
    			num = num + "";
    			var decimalIdx = num.indexOf(".");
    			if(decimalIdx > 0)
    			{ num = num.substring(0, decimalIdx); }
    			return num;
    		}

    		plugin.prototype.ongetNodesError = function(objEvent) {
      			var myStatus = objEvent.target.getRequest().getStatus();
      			jsx3.log("Error","The service call failed. The HTTP Status code is: " + myStatus);
    		}

    		plugin.prototype.ongetNodesInvalid = function(objEvent) {
      			jsx3.log("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
    		}

        });
